package com.controller.lx;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.entity.Diystatus;
import com.service.ServiceException;
import com.service.lx.DiystatusService;
import com.utils.Result;

@Controller
public class DiystatusController {
	@Autowired
	private DiystatusService diystatusService;

	/**
	 * 查询
	 * @return
	 */
	@PostMapping("/diystatus_select_")
	@ResponseBody
	public List<Diystatus> findAll(){
		return diystatusService.findAll();
	}
	
	/**
	 * 查询已启用
	 * @return
	 */
	@PostMapping("/diystatus_select_ok")
	@ResponseBody
	public List<Diystatus> findAllOk(){
		return diystatusService.findAllOk();
	}
	
	/**
	 * 逻辑删除
	 * @param Id
	 * @throws ServiceException
	 */
	@DeleteMapping("/diystatus_ifdelete_")
	@ResponseBody
	public Result UpdateIfdelete(Long Id){
		diystatusService.UpdateUserIfdelete(Id);
		return Result.SUCCESS;
	}

	/**
	 * 批量删除
	 * @param qaIds
	 */
	@PostMapping("/diystatus_delete_arr_")
	@ResponseBody
	public Result deletBatchRoles(@RequestBody JSONArray Ids) {
		diystatusService.deletArrIfDelete(JSONObject.parseArray(Ids.toString(), Long.class));
		return Result.SUCCESS;
	}

	/**
	 * 添加/修改
	 * @param serve
	 * @throws ServiceException
	 */
	@PostMapping("/diystatus_addandupdate_")
	@ResponseBody
	public Result addAndUpdate(@RequestBody Diystatus diystatus){
		diystatusService.addAndUpdateDiystatus(diystatus);
		return Result.SUCCESS;
	}
}
